<div class="bjui-pageContent">
    <form action="${wwwroot}/admin/telnetserver/save" id="editForm" data-toggle="validate" data-alertmsg="false" reloadNavtab="true">
        <input type="hidden" name="id" value="${(telnetServer.id)!}" />
        <div class="pageFormContent" data-layout-h="0">
            <table class="table table-condensed table-hover" width="100%">
                <tbody>
                    <tr>
                        <td>
                            <label for="alias" class="control-label x85">别名：</label>
                            <input type="text" name="alias" id="alias" value="${(telnetServer.alias)!}" data-rule="required" >
                        </td>
                        <#--<td>-->
                            <#--<label for="groupType" class="control-label x85">分组类型：</label>-->
                            <#--<input type="text" name="groupType" id="groupType" value="${(telnetServer.groupType)!}" data-rule="required" >-->
                        <#--</td>-->
                        <td>
                            <label for="agentId" class="control-label x85">代理：</label>
                            <#--<input type="text" name="agentId" id="agentId" value="${(telnetServer.agentId)!}"  >-->
                            <select name="agentId" id="agentId" data-toggle="selectpicker" data-rule="required">
                                <option value="">请选择</option>
                            <#list agents as ag>
                                <option value="${(ag.id)!}" <#if ag??&&ag.id??&&telnetServer.agentId??&&ag.id==telnetServer.agentId>selected</#if>>${(ag.name)!}</option>
                            </#list>
                            </select>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <label for="host" class="control-label x85">地址：</label>
                            <input type="text" name="host" id="host" value="${(telnetServer.host)!}" data-rule="required" >
                        </td>
                        <td>
                            <label for="user" class="control-label x85">账号：</label>
                            <input type="text" name="user" id="user" value="${(telnetServer.user)!}" data-rule="required" >
                        </td>
                        <td>
                            <label for="pass" class="control-label x85">密码：</label>
                            <input type="password" name="pass" id="pass" value="${(telnetServer.pass)!}" data-rule="required" onchange="javascript:genPass()">
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <label for="port" class="control-label x85">端口：</label>
                            <input type="text" name="port" id="port" value="${(telnetServer.port)!}" data-rule="required" >
                        </td>
                        <td>
                            <label for="bizTypeId" class="control-label x85">业务类型：</label>
                            <select name="bizTypeId" id="bizTypeId" data-toggle="selectpicker" onchange="$('#bizTypeName_').val(this.options[this.selectedIndex].text)" data-rule="required">
                                <option value="">请选择</option>
                            <#list bizTypes as type>
                                <option value="${(type.id)!}" <#if type??&&type.id??&&telnetServer.bizTypeId??&&type.id==telnetServer.bizTypeId>selected</#if>>${(type.typeName)!}</option>
                            </#list>
                            </select>
                            <input type="hidden" name="bizTypeName" id="bizTypeName_" value="${(telnetServer.bizTypeName)!}"  >
                            <#--<input type="text" name="bizTypeId" id="bizTypeId" value="${(telnetServer.bizTypeId)!}"  >-->
                        </td>
                        <#--<td>-->
                            <#--<label for="bizTypeName" class="control-label x85">业务类型名称：</label>-->
                            <#--<input type="text" name="bizTypeName" id="bizTypeName" value="${(telnetServer.bizTypeName)!}"  >-->
                        <#--</td>-->
                    </tr>
                    <tr>
                        <td>
                            <label for="team" class="control-label x85">组别：</label>
                            <#--<input type="text" name="team" id="team" value="${(telnetServer.team)!}" data-rule="required" >-->
                            <select name="team" id="team" data-toggle="selectpicker"  data-rule="required">
                                <option value="">请选择</option>
                            <#list teams as team>
                                <option value="${(team)!}" <#if team??&&team.value??&&telnetServer.team??&&team==telnetServer.team>selected</#if>>${(team.label)!}</option>
                            </#list>
                            </select>
                        </td>
                        <td>
                            <label for="opSystem" class="control-label x85">操作系统：</label>
                            <#--<input type="text" name="opSystem" id="opSystem" value="${(telnetServer.opSystem)!}"  >-->
                        <@p.selector osTypes 'typeName' 'typeName' telnetServer 'opSystem' 'opSystemName'/>
                        </td>
                        <td>
                            <label for="sysRank" class="control-label x85">系统级别：</label>
                            <#--<input type="text" name="sysRank" id="sysRank" value="${(telnetServer.sysRank)!}"  >-->
                        <@p.selector systemRanks 'name' 'name' telnetServer 'sysRank' 'sysRankName'/>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <label for="note" class="control-label x85">备注：</label>
                            <input type="text" name="note" id="note" value="${(telnetServer.note)!}"  >
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <a class="btn btn-success" href="javascript:testConnect();">测试连接</a>
                        </td>
                    </tr>
                </tbody>
            </table>
        </div>
    </form>
</div>
<div class="bjui-pageFooter" >
    <ul>
        <li><button type="button" class="btn btn-close" data-icon="close">取消</button></li>
        <li><button type="submit" class="btn btn-success" data-icon="save">保存</button></li>
    </ul>
</div>
<script>
    function genPass()
    {
        var pass = $('#pass').val();
        $.ajax({
            url: "/admin/pass/encrypt"
            , type: "POST"
            , data: "pass="+pass
            , success: function( data, textStatus, jqXHR ){
                $('#pass').val(data)
            }
        });
    }

    function testConnect(){
        var opSystem = $('#editForm select[id=opSystem]').val();
        var host = $('#editForm input[id=host]').val();
        var user = $('#editForm input[id=user]').val();
        var pass = $('#editForm input[id=pass]').val();

        $.ajax({
            url: "/admin/telnetserver/testconnect"
            , type: "POST"
            , data: "opSystem="+opSystem+"&host="+host+"&user="+user+
            "&pass="+pass+"&random="+new Date().getTime()
            ,timeout:15000
            , success: function( data, textStatus, jqXHR ){
                alert(data);
            }
        });
    }
</script>